#include "common.h"


void CreateBiTree(BiTree *T){
    *T=(BiTree)malloc(sizeof(BiTNode));
    //根节点
   (*T)->data=1;
   (*T)->lchild=(BiTree)malloc(sizeof(BiTNode));
   (*T)->rchild=(BiTree)malloc(sizeof(BiTNode));
    //1节点的左孩子2
   (*T)->lchild->data=2;
   (*T)->lchild->lchild=(BiTree)malloc(sizeof(BiTNode));
   (*T)->lchild->rchild=(BiTree)malloc(sizeof(BiTNode));
    //2节点的右孩子5
   (*T)->lchild->rchild->data=5;
   (*T)->lchild->rchild->lchild=NULL;
   (*T)->lchild->rchild->rchild=NULL;
    //1节点的右孩子3
   (*T)->rchild->data=3;
   (*T)->rchild->lchild=(BiTree)malloc(sizeof(BiTNode));
    //3节点的左孩子6
   (*T)->rchild->lchild->data=6;
   (*T)->rchild->lchild->lchild=NULL;
   (*T)->rchild->lchild->rchild=NULL;
   (*T)->rchild->rchild=(BiTree)malloc(sizeof(BiTNode));
    //3节点的右孩子7
   (*T)->rchild->rchild->data=7;
   (*T)->rchild->rchild->lchild=NULL;
   (*T)->rchild->rchild->rchild=NULL;
    //2节点的左孩子4
   (*T)->lchild->lchild->data=4;
   (*T)->lchild->lchild->lchild=NULL;
   (*T)->lchild->lchild->rchild=NULL;
}

void PrintBiT(BiTree elem){
    printf("%d ",elem->data);
}